import QtQuick 2.6

import "Base/UiBase"
import "Base/Config"

import Cpp.Utility 1.0 as Utility

Rectangle {
    id: root

    property Item indexRoot: indexLoader

    Keys.onReleased: {
        if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) {
            event.accepted = true
            Qt.quit()
        }
    }

    focus: true
    visible: true
    color: Color.background

    Loader {
        id: indexLoader
        width: parent.width
        anchors {
            top: parent.top
            bottom: menuBar.top
        }
        property var sources: ({
                                   evaluation: "Evaluation/Index.qml",
                                   discover: "Discover/Index.qml",
                                   tc: "TCommunity/Index.qml",
                                   personal: "Personal/Index.qml",
                                   about: "About/Index.qml"
                               })

        source: sources[menuBar.page]
        onSourceChanged: {
            if (Qt.platform.os === "windows")
                Utility.Engine.trim()
        }
    }

    MenuBar {
        id: menuBar
        width: parent.width
        anchors.bottom: parent.bottom
        z: 1
        page: "evaluation"

        TopDivider {
        }
    }
}
